package converter;

import java.io.DataOutputStream;
import java.io.IOException;

public class Map {
	private int width;
	private int heigth;
	private String tileset;
	private long[] bottom;
	private long[] top;
	private Sprite[] objects;
	private long[] middle;
	
	public long[] getMiddle() {
		return middle;
	}
	protected int getWidth() {
		return width;
	}
	public void setWidth(int width) {
		this.width = width;
	}
	public int getHeigth() {
		return heigth;
	}
	public void setHeigth(int heigth) {
		this.heigth = heigth;
	}
	public String getTileset() {
		return tileset;
	}
	public void setTileset(String tileset) {
		this.tileset = tileset;
	}
	public long[] getBottom() {
		return bottom;
	}
	public void setBottom(long[] ls) {
		this.bottom = ls;
	}
	public long[] getTop() {
		return top;
	}
	public void setTop(long[] ls) {
		this.top = ls;
	}
	public Sprite[] getObjects() {
		return objects;
	}
	public void setObjects(Sprite[] objects) {
		this.objects = objects;
	}
	public void setWidth(String width2) {
		setWidth(Integer.parseInt(width2));
	}
	public void setHeigth(String height) {
		setHeigth(Integer.parseInt(height));
	}
	public void save(DataOutputStream file) throws IOException {
		byte identifier[] = {'M', 'P', 'D', 'K', 0, 1};
		file.write(identifier);
		file.writeInt(width);
		file.writeInt(heigth);
		file.writeUTF(tileset);
		for (int i = 0; i < bottom.length; i++) {
			file.writeInt((int)bottom[i]);
		}
		for (int i = 0; i < middle.length; i++) {
			file.writeInt((int)middle[i]);
		}
		for (int i = 0; i < top.length; i++) {
			file.writeInt((int)top[i]);
		}
		file.writeInt(objects.length);
		for (int i = 0; i < objects.length; i++) {
			objects[i].save(file);
		}
	}
	public void setMiddle(long[] ls) {
		this.middle =ls;
	}
}
